﻿<template>
    <div id="app">
        <mt-header v-bind:title="title" style="background-color:#fda10e">
            <a slot="left" @click="back()">返回</a>

        </mt-header>
        <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
        <div class="mui-card">
            <div class="mui-card-header">{{info.title}}</div>
            <div class="mui-card-content">
                <div class="mui-card-content-inner" v-if="info.imgurl!=''">
                    <img :src="info.imgurl" style="width:98%;" />
                </div>
                <div class="mui-card-content-inner">
                    <p v-html="html">{{info.desc}}</p>
                </div>
            </div>
            <div class="mui-card-footer">发布人:{{info.teachername}}</div>
            <div class="mui-card-footer">发布时间:{{info.createtime}}</div>
            <div class="mui-card-footer">作业完成时间:{{info.overtime}}</div>


        </div>
        <div class="mui-card" v-if="usertype==1">
            <div class="mui-card-header">我的反馈</div>
            <div class="mui-card-content" v-for="item in info.workresult">
                <div class="mui-card-content-inner" v-if="item.imglist!=''">

                    <img :src="img" style="width:100px;" @click="clickImg($event)" v-for="img in item.imglist" />
                </div>
                <div class="mui-card-content-inner">
                    {{item.desc}}
                </div>
                <div class="mui-card-footer">反馈时间: {{item.createtime}}</div>
            </div>

          


        </div>
        <div class="mui-card" v-if="usertype==2">
            <div class="mui-card-header">学生反馈</div>

        </div>

        <template v-for="item in info.workresult" v-if="info.workresultstate==2">
            <div class="mui-card">


                <div class="mui-card-header">学生姓名:{{item.studentname}}</div>
                <div class="mui-card-content">
                    <div class="mui-card-content-inner" v-if="item.imglist!=''">
                        <img :src="img" style="width:100px;" @click="clickImg($event)" v-for="img in item.imglist" />
                    </div>
                    <div class="mui-card-content-inner">
                        {{item.desc}}
                    </div>
                </div>


                <div class="mui-card-footer">反馈时间:{{item.createtime}}</div>
            </div>
        </template>





        <div v-if="usertype==1" style="height:50px;background-color:#fda10e;width:100%;font-size:18px;text-align:center;line-height:50px;vertical-align:middle;">
            <a style="color:#ffffff" @click="fankui">我要反馈</a>
        </div>

    </div>
</template>

<script>
    import BigImg from '../components/BigImg.vue';
    import Bus from '../bus.js'
    export default {
        name: 'app',
        data() {
            return {
                title: "作业",
                info: {},
                showImg: false,
                imgSrc: '',
                html: "",
                usertype: "",


            }
        },
        components: {
            'big-img': BigImg
        },
        methods:
        {
            clickImg(e) {
                this.showImg = true;
                // 获取当前图片地址
                this.imgSrc = e.currentTarget.src;
            },
            viewImg() {
                this.showImg = false;
            },
            fankui: function () {

                this.$router.push({ name: 'workfankui', params: { id: this.$data.info.id } });

            },
            load: function () {
                var id = this.$route.params.id;

                var studentid = window.localStorage.getItem("studentid");
                var teacherid = window.localStorage.getItem("teacherid");
              
             
                console.log(this.$route.params);
                var _this = this;
                this.$api.post('wx/Index/getworkinfo', {
                    "id": id,
                    "studentid": studentid,
                    "teacherid": teacherid
                }, response => {
                    if (response.status >= 200 && response.status < 300) {
                        console.log(response.data);
                        var data = response.data;
                        if (data.status == 200) {
                            _this.$data.info = data.data;
                            _this.$data.html = data.data.desc;

                        }

                        //请求成功，response为成功信息参数
                    } else {
                        console.log(response.message);
                        //请求失败，response为失败信息
                    }
                });
            },
            back: function () {
                Bus.$emit('val', "hide");
                this.$router.go(-1);
            }
        },
        created: function () {
    
            this.$data.usertype = window.localStorage.getItem("usertype");
            this.load();

        }
    }
</script>

<style scoped>
</style>